package com.javajun.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

@Entity(name="xlm_claxx")
public class Claxx {

	private Integer id;
	// 名字
	private String name;
	// 班主任对象
	private Manager manager;
	// 学生集合
	private List<Student> students = new ArrayList<>();
	// 主修课程集合
	private List<MainCourse> mainCourses = new ArrayList<>(); 
	
	// SuperClass
	public Claxx() {
		super();
	}
	
	// Getters And Setters
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(length=20)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@OneToMany(fetch=FetchType.LAZY, mappedBy="claxx")
	public List<Student> getStudents() {
		return students;
	}
	public void setStudents(List<Student> students) {
		this.students = students;
	}
	@ManyToOne(fetch=FetchType.EAGER)
	@NotFound(action=NotFoundAction.IGNORE)
	public Manager getManager() {
		return manager;
	}
	public void setManager(Manager manager) {
		this.manager = manager;
	}

	@ManyToMany(fetch=FetchType.LAZY)
	public List<MainCourse> getMainCourses() {
		return mainCourses;
	}
	public void setMainCourses(List<MainCourse> mainCourses) {
		this.mainCourses = mainCourses;
	}

}
